<template>
  <div>
    <el-form label-width="80px">
      <el-row>
        <template v-for="item in formItem" :key="item.label">
          <el-col :span="8">
            <el-form-item :label="item.label">
              <!-- 表单为input框时 -->
              <template
                v-if="item.type === 'input' || item.type === 'password'"
              >
                <el-input
                  v-bind="item.otherOptions"
                  :placeholder="item.placeholder"
                  :show-password="item.type == 'password'"
                ></el-input>
              </template>
              <!-- 表单为下拉框时 -->
              <template v-else-if="item.type === 'select'">
                <el-select style="width:100%" :placeholder="item.placeholder">
                  <template
                    v-for="option in item.selectOptions"
                    :key="option.title"
                  >
                    <el-option v-bind="item.otherOptions" :value="option.value">
                      {{ option.title }}
                    </el-option>
                  </template>
                </el-select>
              </template>
              <!-- 表单为日期选择框时 -->
              <template v-else-if="item.type === 'datepicker'">
                <el-date-picker
                  v-bind="item.otherOptions"
                  :placeholder="item.placeholder"
                >
                </el-date-picker>
              </template>
            </el-form-item>
          </el-col>
        </template>
      </el-row>
    </el-form>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    formItem: {
      type: Array,
    },
  },
  setup() {
    return {};
  },
});
</script>

<style scoped></style>
